﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddTrainClass.aspx.cs" Inherits="TrainClassManagement_AddTrainClass" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
    <script src="../Js/LoginNameCheck.js" type="text/javascript"></script>
    <link href="../Css/ys.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/jscript" src="../My97DatePicker/WdatePicker.js"></script>
    <script src="../Js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/jscript">

        function validateTrainClassId(trainclassId) {
            var schoolId = $("#hfSchoolID").val();
            if (trainclassId == "") {
                alert("培训班编号不能为空！");
                return false;
            }
            var flag = AjaxMethodHelper.IsExistTrainClassIdBySchoolId(schoolId, trainclassId);
            if (!flag.value) {
                //$("#lblTrainClassIdInfo").val("此培训班编号已经存在，请输入其他培训班编号！");
                alert("此培训班编号已经存在，请输入其他培训班编号！");
              
                return false;
            }
            else {
                //$("#lblTrainClassIdInfo").val("此培训班编号可用！");
                return true;
            }
        }
        function validateControl(schoolId) {
            if (!this.validateTrainClassId(schoolId,$("#txtvtcNum").val())) {
                alert("培训班编号已经存在，请输入其他培训班编号！");
            }
        }
    </script>
    <script type="text/javascript">

        function caculate_length()   //检测剩余可输入字符数   
        {
            var ShortCommodityName = $("#txtTrainMessage").val();
            var Ennum = 0;
            var Chnum = 0;
            newarry = ShortCommodityName.split("");
            for (i = 0; i < newarry.length; i++) {
                if (ischinese(newarry[i])) {
                    Chnum = parseInt(Chnum) + 2;
                }
                else {
                    Ennum = parseInt(Ennum) + 1;
                }
            }
            var text_length = Chnum + Ennum;
            var text_max_length = 2000;
            var target_div = document.getElementById("fontNum");
            var text_remain = text_max_length - text_length;
            if (text_remain <= 0) {
                var charsum = Chnum / 2 + Ennum - 1;
                var text_remainstr = $("#txtTrainMessage").val().substring(charsum, 140);
                $("#txtTrainMessage").val($("#txtTrainMessage").val().replace(text_remainstr, ''));
                text_remain = 0;
            }
            target_div.innerHTML = "<font   color=#ff0000>" + text_remain + "</font>";
        }

        function ischinese(strword) {
            var newPar = /[^\u4E00-\u9FA5]/g
            return !newPar.test(strword);
        }

    </script>

</head>
<body>
    <form id="form2" runat="server">
    <div class="zt mainCenter">
        <div class="contentBody">
        <div class="title">
        培训班管理-->添加培训班信息
        </div>
            <table style="width:100%;color:#336699;"  class="ta1">
            <tr><td class="ta2 tag" >隶属学校</td>
            <td class="ta2">
                <asp:DropDownList ID="dlschool" runat="server" DataTextField="VS_name" 
               DataValueField="ID" CssClass="inp2">
                </asp:DropDownList>
            </td>
            </tr>
              <tr>
              <input type="hidden" id="hfSchoolID" runat="server" />
                    <td class="ta2 tag" >
                                                培训班编号</td>                                               
                    <td class="ta2"  >
                        <input type="text" id="txtvtcNum" runat="server" class="inp1" onblur="return validateTrainClassId(this.value)" /><label id ="lblname" style ="color:Red; font-size:small"></label><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Text="*"  ControlToValidate="txtTrainClasseName"  ErrorMessage="培训班编号不能为空" ValidationGroup="register"></asp:RequiredFieldValidator>
                        <asp:Label ID="lblTrainClassIdInfo" runat="server" ></asp:Label>
                    </td>
                </tr>
             <tr>
                    <td class="ta2 tag">
                                                培训班名</td>
                    <td class="ta2"  >
                        <asp:TextBox ID="txtTrainClasseName" runat="server" CssClass="inp1"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Text="*"  ControlToValidate="txtTrainClasseName"  ErrorMessage="培训班名不能为空" ValidationGroup="register"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                  <tr>
                    <td class="ta2 tag" >
                                                培训人数（最大值）</td>
                    <td class="ta2"  >
                        <asp:TextBox ID="txtMaxCount" runat="server" CssClass="inp1" 
                            ontextchanged="txtMaxCount_TextChanged" AutoPostBack="true"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" Text="*"  ControlToValidate="txtTrainClasseName"  ErrorMessage="培训班人数不能为空" ValidationGroup="register"></asp:RequiredFieldValidator>
                   <asp:Literal ID="ltrChk" runat="server" Visible=false><font color=red>请输入数字</font></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td class="ta2 tag" >
                                                培训班上课日期</td>
                    <td class="ta2"  >
                        <asp:TextBox ID="txtStarDate" runat="server" CssClass="inp1 Wdate" onfocus="new WdatePicker({dateFmt:('yyyy-MM-dd')})"></asp:TextBox>
                          <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                            Text="*"  ControlToValidate="txtStarDate"  ErrorMessage="课程名不能为空" 
                            ValidationGroup="register"></asp:RequiredFieldValidator>
                        
                    </td>
                </tr>
                <tr>
                    <td class="ta2 tag" >
                                                培训班上课截止日</td>
                    <td class="ta2"  >
                        <asp:TextBox ID="txtEndDate" runat="server" CssClass="inp1 Wdate" onfocus="new WdatePicker({dateFmt:('yyyy-MM-dd')})"></asp:TextBox>
                          <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                            Text="*"  ControlToValidate="txtEndDate"  ErrorMessage="课程名不能为空" 
                            ValidationGroup="register"></asp:RequiredFieldValidator>
                        
                    </td>
                </tr>
                 <tr>
                    <td class="ta2 tag"  >
                         启用：
                    </td>
                    <td  class="ta2"   >
                        <asp:CheckBox ID="chkIsEnable" runat="server" Checked="true" />
                    </td>
                </tr>
                <tr>
                    <td class="ta2 tag" rowspan="6">
                        培训班描述：
                    </td>
                    <td class="ta2" rowspan="6">
                     <asp:TextBox ID="txtTrainMessage" runat="server" TextMode="MultiLine" Height="206px" Width="297px" MaxLength="2000" onkeyup="caculate_length()"   CssClass="inp3"></asp:TextBox>
                       
                    </td>
                     
                </tr>
             
            </table>
            <span class="fl">你还剩余<span id='fontNum'>2000</span>字可输入</span>
            <asp:Button ID="btnReg" runat="server" Text="添加" CssClass="button"  ValidationGroup="register"
                onclick="btnReg_Click" />&nbsp;&nbsp;<input type="button" onclick="this.form.reset(); " value="重置" class="button"  id="btnReset" runat="server"/>
            
            <br />
            <p style="color:Red; text-align:left"><asp:Label ID="Label1" runat="server"   ></asp:Label></p>
            <p style="margin-left:50px"><asp:ValidationSummary ID="validSummary" runat="server"   HeaderText="错误信息" ValidationGroup="register" Height="194px" /> 
        </div>
    </div>
  </form>
</body>
</html>
